<template>
	<view class="container">
		<view class="box fitst mgt0">
			<view class="title">
				{{listdata.info.name || ""}}
			</view>
			<view class="item">
				<text>开始日期：</text>{{start_at|| ""}}
			</view>
			<view class="item">
				<text>截止日期：</text>{{end_at || ""}}
			</view>
			<view class="item" v-if="listdata.info.sign_time_status==1"> <text>签到时段：</text>{{signinbetweentime}}</view>
<!-- 			<view class="item" v-if="listdata.info.token_status==1 && navselect==3"> <text>签到口令：</text>{{listdata.info.token || ""}}
			</view> -->
			<view class="item"> <text>签到序号：</text>{{listdata.info.code || ""}} </view>
			<view class="item" v-if="listdata.info.location_status==1">
				<text>地址信息：</text>{{listdata.info.location_address || ""}}
			</view>

		</view>
		<view class="box second">
			{{listdata.info.content || ""}}
		</view>

		<view class="items" v-if="navselect!=3">
			<!-- 文本 -->
			<block v-for="(item,index) in fromData" :key="index">
				<view class="item flex" v-if="item.form_data_type==1">
					<text class="label">{{item.title}}</text>
					<input type="text" v-model="item.value" v-if="item.is_required==1" placeholder="必填项"
						placeholder-style="color:#000" />
					<input type="text" v-model="item.value" v-else placeholder="选填项" placeholder-style="color:#000" />
				</view>
				<!-- 手机号 -->
				<view class="item flex" v-if="item.form_data_type==10">
					<text class="label">{{item.title}}</text>
					<input type="text" v-model="item.value" v-if="item.is_required==1" placeholder-style="color:#000"
						placeholder="必填项" />
					<input type="text" v-model="item.value" placeholder-style="color:#000" v-else placeholder="选填项" />
				</view>
				<!-- 图片 -->
				<view class="item heightmin flex space-between" v-if="item.form_data_type==5">
					<text class="label mgr-6  ">{{item.title}}</text>
					<text class="text fsize28 mgr-6" v-if="item.is_required==0 &&  item.value==''">选填项</text>
					<text class="text fsize28 mgr-6" v-if="item.is_required==1 && item.value==''">必填项</text>
					<uni-icons type="image-filled" size="25" @click="picture(index)"
						v-if="item.value=='' || item.value==undefined "></uni-icons>
					<view class="cover" v-else @click="picture(index)">
						<image :src="item.value" mode="aspectFit" />
					</view>
				</view>
				<!-- 拍照 -->
				<view class="item heightmin flex  space-between" v-if="item.form_data_type==11" @click="camera(index)">
					<text class="label ">{{item.title}}</text>

					<uni-icons type="camera" size="25" v-if="item.value=='' || item.value==undefined"></uni-icons>
					<view class="cover" v-else>
						<image :src="item.value" mode="aspectFit" />
					</view>
				</view>

				<!-- 定位 -->
				<view class="item flex space-between" v-if="item.form_data_type==4" @click="localtion(index)">
					<text class="label ">{{item.title}}</text>
					<!-- 					<text class="text" v-if="item.is_required==0 && item.value==''">选填项</text>
					<text class="text" v-if="item.is_required==1 && item.value==''">必填项</text> -->
					<!-- <text class="text" v-if="item.value!=''">{{item.value || '请选择位置'}}</text> -->
					<text class="text">{{item.value || '请选择位置'}}</text>
					<uni-icons type="map-pin-ellipse" size="25"></uni-icons>
				</view>

				<!-- 昵称 -->
				<view class="item flex space-between" v-if="item.form_data_type==6" @click="nickname(item,index)">
					<view class="flex">
						<text class="label">{{item.title}}</text>
						<input type="text" v-model="item.value" v-if="item.is_required==1" placeholder="必填项"
							placeholder-style="color:#000" />
						<input type="text" v-model="item.value" v-else placeholder-style="color:#000"
							placeholder="选填项" />
					</view>
					<uni-icons type="person-filled" size="25"></uni-icons>
				</view>
				<!-- 日期＋时间 -->
				<view class="item flex  space-between" v-if="item.form_data_type==7">
					<text class="label">{{item.title}}</text>

					<uni-datetime-picker v-model="item.value" @change="this.$forceUpdate()">
						<block v-if="item.value==''">
							<uni-icons type="right" size="25"></uni-icons>
						</block>
						<block v-else>{{item.value}}</block>
					</uni-datetime-picker>
				</view>
				<!-- 日期＋ -->
				<view class="item flex  space-between" v-if="item.form_data_type==8" @change="this.$forceUpdate()">
					<text class="label">{{item.title}}</text>

					<uni-datetime-picker type="date" v-model="item.value">
						<block v-if="item.value==''">
							<uni-icons type="right" size="25"></uni-icons>
						</block>
						<block v-else>{{item.value}}</block>
					</uni-datetime-picker>
				</view>
				<!-- 时间 -->
				<view class="item flex  space-between" v-if="item.form_data_type==9" @click="bindTimeClick(item,index)">
					<text class="label">{{item.title}}</text>
					<picker mode="time" :value="item.value" start="00:00" end="23:59" @change="bindTimeChange">
						<view class="uni-input">{{item.value}}</view>
					</picker>
				</view>

				<!-- 单选 -->
				<view class="item heightmin flex  space-between" v-if="item.form_data_type==2"
					@click="showradio(item,index)">
					<text class="label"> {{item.title}} </text>
					<view class="moreoptionstyle">
						<!-- <text class=" fsize28">{{item.value}}</text> -->
						<text class="text  fsize28" v-if="item.is_required==0 && item.value==''">选填项</text>
						<text class="text  fsize28" v-if="item.is_required==1 && item.value==''">必填项</text>
						<text class="text  fsize28" v-if="item.value!=''">{{item.value}}</text>

					</view>

					<view class="">
						<uni-icons type="right" size="25"></uni-icons>
					</view>
				</view>
				<!-- 多选 -->
				<view class="item heightmin flex  space-between" v-if="item.form_data_type==3"
					@click="optionmore(item,index)">
					<view class="flex">
						<text class="label  "> {{item.title}} </text>
						<view class="moreoptionstyle">
							<!-- <text class="fsize28 mgr-6" v-for="(ttt,iii) in item.value" :key="iii">{{ttt}}</text> -->
							<text class="text fsize28 mgr-6" v-if="item.is_required==0 && item.value==''">选填项</text>
							<text class="text fsize28 mgr-6" v-if="item.is_required==1 && item.value==''">必填项</text>
							<text class="text fsize28 mgr-6" v-for="(ttt,iii) in item.value" :key="iii"
								v-if="item.value!=''">{{ttt}}</text>
						</view>
					</view>
					<view class="">
						<uni-icons type="right" size="25"></uni-icons>
					</view>
					<!-- 					<input type="text" v-if="item.is_required==1" placeholder="必填项" />
					<input type="text" v-else placeholder="选填项" /> -->
				</view>
			</block>
		</view>
		<view class="mask" v-if="moreOption || radioshow"> </view>

		<!-- 单选 -->
		<view class="option" v-if="radioshow">
			<view class="title">
				{{options_item.title}}
			</view>
			<view class="option-box">
				<!--单选 -->
				<view class="item height85" :class="{bgblue:options_item.value==ttt}"
					v-for="(ttt,iii) in options_item.options" :key="iii" @click="single1(ttt)">
					{{ttt}}
				</view>

			</view>
			<view class="btns">
				<view class="btn" @click="optionCalcel">
					取消
				</view>
				<view class="btn bgblue" @click="singleOK">
					确定
				</view>
			</view>
		</view>

		<!-- 多选 -->
		<view class="option" v-if="moreOption">
			<view class="title">
				{{options_item.title}}
			</view>
			<view class="option-box">
				<block v-for="(ttt,iii) in options_item.options" :key="iii">
					<view class="item height85" :class="{bgblue:options_item.value.indexOf(ttt)>-1}"
						@click="double(ttt)">
						{{ttt}}
					</view>
				</block>
			</view>
			<view class="btns">
				<view class="btn" @click="moreoptionCalcel">
					取消
				</view>
				<view class="btn bgblue" @click="doubleOK">
					确定
				</view>
			</view>
		</view>



		<view class="button" @click="signIn" v-if="navselect == 1">
			签到
		</view>
	
		<view class=" button button1" v-else-if="navselect == 3">
			已签到
		</view>
		<view class=" button button1" v-else>
			未在签到时间内
		</view>
		<mask-model ref="showMask" btnType="1" fontsize="38rpx" @confirm="confirm" @cancel="cancel" titleColoe="#666666"
			cancelColor="#666666" confirmColor="#007AFF" maskTitle="签到成功"></mask-model>
		<mask-model ref="showMaskerror" btnType="1" titleColoe="#666666" cancelColor="#666666" confirmColor="#007AFF"
			:maskTitle="showtoast"></mask-model>
		<view v-if=" wxapp_banner_adv" class="ad">
			<ad :unit-id="wxapp_banner_adv" bindload="adLoad" binderror="adError" bindclose="adClose"></ad>
		</view>


	</view>
</template>

<script>
	import {
		signDo,
		signInfo
	} from '@/api/activity.js';
	import {
		upload,
		getConfig
	} from "@/api/index.js";
	import {
		gettoken,
	} from '@/api/login.js';
	import {
		getInfo,
	} from "@/api/user.js"
	import maskModel from '../../components/mask-model/mask-model.vue'
	export default {
		data() {
			return {
				code: "",
				listdata: [],
				longitude: "",
				latitude: "",
				fromData: [],
				date: "", //日期
				isoption: false, //是否展示选项的悬浮框
				single: "",
				options_index: 0,
				options_item: {},
				more_options_item: [],
				radioshow: false,
				moreOption: false,
				navselect: "",
				signinbetweentime: "",
				end_at: "",
				start_at: "",
				adContainer: "", //广告位,
				wxapp_banner_adv: "",
				wxapp_window_adv: "",
				interstitialAd: "",
				showtoast: "",
				res_longitude: '',
				res_latitude: '',
			}
		},
		onLoad(options) {
			let that = this;
			console.log('options', options);
			if (options.scene) {
				let scene = decodeURIComponent(options.scene);
				console.log(scene);
				this.code = scene;
				// 后续处理scene
			}
			if (options.code) {
				this.code = options.code;
				console.log(this.code, 'codecode');
			}
			// this.navselect = options.navselect;
			uni.showLoading({
				title: '正在加载···'
			})
			if (!uni.getStorageSync('token')) {
				uni.login({
					provider: 'weixin',
					success: function(info) {
						console.log('login', info);
						gettoken({
							data: {
								code: info.code,
							}
						}).then(res => {
							console.log(res);
							uni.hideLoading();
							uni.setStorageSync('token', res.data.token.token);
							that.init();
						})
					}
				});
			} else {
				that.init();
			}


		},
		onShow() {

		},
		onReady() {},
		methods: {
			confirm: function(e) { //确定按钮
				this.navselect = 3
				this.$forceUpdate()
			},
			cancel: function() { //取消按钮
				console.log('您点击了取消按钮');
				this.navselect = 3
				this.$forceUpdate()
				this.interstitialAd.show().catch((err) => {
					console.error(err)
				})
			},

			hidemodal() {
				// this.isoption = false;
				this.radioshow = false;
				this.moreOption = false
			},
			nickname(item, index) {
				getInfo({
					data: {}
				}).then(res => {
					if (res.code == 1) {
						console.log(res.data)
						if (res.data.user.username) {
							this.fromData[index].value = res.data.user.username
						} else {
							this.fromData[index].value = res.data.user.nickname
						}
					}
				})
				this.$forceUpdate()
			},
			bindTimeClick(item, index) {
				// this.fromData[index].value=this.time;
				this.options_index = index;
				console.log(this.fromData[index].value);
			},
			bindTimeChange(e) {
				this.fromData[this.options_index].value = e.detail.value;
				this.$forceUpdate()
			},

			showradio(item, index) {
				this.lastdata = this.fromData[this.options_index].value
				this.options_index = index;
				if (item.form_data_type == 2) {
					this.options_item = JSON.parse(JSON.stringify(item));
					this.fromData[index].value = ""
					// console.log(this.fromData[index].value,'this.fromData');
					// 展示单选弹窗
					this.radioshow = true;
				}
			},
			optionmore(item, index) {
				this.options_index = index;
				if (item.form_data_type == 3) {
					this.options_item = JSON.parse(JSON.stringify(item));
					// 展示多选弹窗
					this.moreOption = true;
				}
			},
			moreoptionCalcel() {
				this.moreOption = false;
				this.$forceUpdate();
			},
			optionCalcel() {
				this.radioshow = false;
				this.$forceUpdate();
			},

			doubleOK() {
				this.fromData[this.options_index].value = this.options_item.value
				this.moreOption = false;
				this.$forceUpdate();
			},
			singleOK() {
				this.fromData[this.options_index].value = this.options_item.value
				this.radioshow = false;
				this.$forceUpdate();
			},
			init() {
				getConfig({
					data: {
						code: this.code
					}
				}).then(res => {
					if (res.code == 1) {
						console.log(res.data, '	{{wxapp_banner_adv}},');
						this.wxapp_banner_adv = res.data.wxapp_banner_adv
						this.wxapp_window_adv = res.data.wxapp_window_adv
						if (uni.createInterstitialAd) {
							console.log(this.wxapp_window_adv,
								'里面的值');
							this.interstitialAd = uni.createInterstitialAd({
								adUnitId: this.wxapp_window_adv
							})
							this.interstitialAd.onLoad(() => {
								console.log('onLoad event emit')
							})
							this.interstitialAd.onError((err) => {
								console.log('onError event emit', err)
							})
							this.interstitialAd.onClose((res) => {
								console.log('onClose event emit', res)
							})
						}
					}
				})


				var myDate = new Date()
				signInfo({
					data: {
						code: this.code
					}
				}).then(res => {
					if (res.code == 1) {
						this.navselect = res.data.info.can_sign;
						console.log('signin 数据 ，内容 res.data', res.data)
						this.listdata = res.data;
						let fromData = res.data.from_data;

						this.start_at = this.listdata.info.start_at.substr(0, this.listdata.info.start_at.length -
							3)
						this.end_at = this.listdata.info.end_at.substr(0, this.listdata.info.end_at.length - 3)

						if (res.data.sign_time.length > 0) {
							console.log('进来了');
							// 截取签到时段
							for (let ttt in this.listdata.sign_time) {
								console.log(this.listdata.sign_time[ttt][0].substr(0, 5),
									'listdata.sign_time[ttt]');
								console.log(this.listdata.sign_time[ttt][1].substr(0, 5),
									'listdata.sign_time[ttt]');
								this.signinbetweentime = this.signinbetweentime + this.listdata.sign_time[ttt][0]
									.substr(0, 5) + '-' + this.listdata.sign_time[ttt][1].substr(0, 5) + '、'
							}
							this.signinbetweentime = this.signinbetweentime.substr(0, this.signinbetweentime
								.length - 1)
						}
						console.log('过来了');
						// 判断数据类型
						if (res.data.length != 0) {
							for (let i in fromData) {
								if (fromData[i].form_data_type == 2) {
									fromData[i]['value'] = '';
								} else if (fromData[i].form_data_type == 3) {
									fromData[i]['value'] = [];
								} else if (fromData[i].form_data_type == 7) {
									fromData[i]['value'] = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) +
										'-' +
										myDate.getDate() + ' ' + myDate.getHours() + ':' + myDate.getMinutes() +
										':' +
										myDate.getSeconds();
								} else if (fromData[i].form_data_type == 8) {
									fromData[i]['value'] = myDate.getFullYear() + '-' + (myDate.getMonth() + 1) +
										'-' +
										myDate.getDate();
								} else if (fromData[i].form_data_type == 9) {
									fromData[i]['value'] = myDate.getHours() + ':' + myDate.getMinutes() + ':' +
										myDate
										.getSeconds();
								} else {
									fromData[i].value = '';
								}
							}
						}
						this.fromData = fromData;
						JSON.parse(JSON.stringify(this.fromData))
						console.log(JSON.parse(JSON.stringify(this.fromData)), 'this.fromData');
						// console.log(this.fromData, 'this,fromData');

						const dataArray = uni.getStorageSync('dataArray');
						console.log(dataArray, 'dataArray的值');

						for (var i in this.fromData) {
							for (var j in dataArray) {
								if (this.fromData[i].title == dataArray[j].title) {
									this.fromData[i].value = dataArray[j].value

								}
							}
						}

						uni.hideLoading()
					}
				})
			},
			option() {
				this.isoption = true
			},
			single1(e) {
				//刚才的值
				// 把选中数据的值 赋值给  该大数据的value值
				//最新的值
				// 当前选中项的value 等于 
				this.options_item.value = e;
				this.$forceUpdate();
			},
			double(e) {
				//  这个多选项的  所点击的一条的 数据 
				// this.more_options_item=this.fromData[this.options_index].value
				// console.log(e, 'eeee');
				let index = this.options_item.value.indexOf(e);
				// console.log(index, 'index');
				if (index > -1) {
					//移除数组中的数据，index为从第几个开始数，1为移除几个。
					this.options_item.value.splice(index, 1);
					console.log(this.options_item.value, 'remove');
				} else {
					this.options_item.value.push(e);
				}
				// console.log(this.fromData[this.options_index].value);
				console.log(this.options_item.value, 'this.options_item.value');
				this.$forceUpdate();
			},
			picture(index) {
				let that = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						let imagepath = res.tempFilePaths;
						for (let i in imagepath) {
							upload({
								filePath: imagepath[i]
							}).then(res => {
								if (res.code == 1) {
									that.fromData[index].value = res.info.url;
									that.$forceUpdate();
								}
							})
						}
					}
				});
			},
			camera(index) {
				let that = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['camera'], //从相册选择
					success: (res) => {
						let imagepath = res.tempFilePaths;
						for (let i in imagepath) {
							upload({
								filePath: imagepath[i]
							}).then(res => {
								if (res.code == 1) {
									that.fromData[index].value = res.info.url;
									that.$forceUpdate();
								}
							})
						}
					}
				});
			},


			localtion(index) {
				let that = this;
				uni.getLocation({
					type: 'gcj02',
					geocode: true,
					success: function(res) {
						console.log(res);
						console.log('当前位置的经度：' + res.longitude);
						console.log('当前位置的纬度：' + res.latitude);
						that.res_longitude = res.longitude;
						that.res_latitude = res.latitude;
						uni.request({
							url: 'https://restapi.amap.com/v3/geocode/regeo',
							method: 'GET',
							data: {
								location: res.longitude + ',' + res.latitude,
								key: '83a2cb04cb7c947dfeaa59583f4823da', // batch:false,

							},
							success: function(res) {
								console.log("-------------------> 城市解析");
								console.log(res.data.regeocode.formatted_address);
								// _this.geography = res.data.regeocode.formatted_address;
								that.fromData[index].value = res.data.regeocode.formatted_address
								that.$forceUpdate()
							},
							fail: function(err) {
								console.log('地址解析失败' + err);
							}
						})
					}, 
					fail: res => {
						if (that.res_longitude == '') {
							uni.showToast({
								title: '位置信息获取失败，请稍后重试',
								icon: 'none'
							});
							return;
						}
						uni.request({
							url: 'https://restapi.amap.com/v3/geocode/regeo',
							method: 'GET',
							data: {
								location: that.res_longitude + ',' + that.res_latitude,
								key: '83a2cb04cb7c947dfeaa59583f4823da', // batch:false,

							},
							success: function(res) {
								console.log("-------------------> 城市解析");
								console.log(res.data.regeocode.formatted_address);
								// _this.geography = res.data.regeocode.formatted_address;
								that.fromData[index].value = res.data.regeocode.formatted_address
								that.$forceUpdate()
							},
							fail: function(err) {
								console.log('地址解析失败' + err);
							}
						})
					}
				});
				// let that = this;
				// uni.chooseLocation({
				// 	success: res => {
				// 		console.log('详细地址：' + res.address);
				// 		console.log(that.fromData[index], 'that.fromData[index]');
				// 		console.log(index, 'inmdex');
				// 		that.fromData[index].value = res.address
				// 		this.$forceUpdate()
				// 	}
				// });
			},


			saveDataArray(data) {
				const dataArray = uni.getStorageSync('dataArray');
				// console.log(data, 'data的数据');
				// console.log(dataArray, 'dataArray的数据');
				const newdataArray = JSON.parse(JSON.stringify(data)).concat(dataArray)
				console.log('arrayResult', newdataArray)
				// console.log(Array.from(newdataArray.title));
				let newArr = []
				newdataArray.forEach((item) => {
					let isClude = false
					newArr.forEach((item1) => {
						if (JSON.stringify(item.title) === JSON.stringify(item1.title)) {
							isClude = true
						}
					})
					if (!isClude) {
						newArr.push(item)
					}
				})
				console.log('newArr', newArr)

				for (var i in newArr) {
					if (newArr[i].form_data_type === 4) {
						newArr.splice(i, 1);
					}
				}

				// if(dataArray[j].form_data_type===10){

				uni.setStorage({
					key: 'dataArray',
					data: newArr,
					success: function() {
						console.log('success');
					}
				});


			},

			signIn() {
				let that = this;

				function timestampToTime(timestamp) {
					var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
					var Y = date.getFullYear() + '-';
					var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
					var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
					var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
					var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
					var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
					return Y + M + D + h + m + s;
				}
				var timestamp = Date.parse(new Date());
				// timestampToTime(timestamp);
				// console.log(timestampToTime(timestamp), '这是时间'); //2020-06-18 10:33:24
				let _sendflag = true
				let datatimenow = timestampToTime(timestamp)
				console.log(this.listdata.info, 'this.listdata.infothis.listdata.infothis.listdata.info');
				if (datatimenow < this.listdata.info.start_at ) {
						uni.showToast({
							title: '当前签到未开始！',
							icon: "none",
							duration: 2000
						});
						return
					}
				// 首先判断是否在签到时间之内
			
				if (datatimenow < this.listdata.info.end_at) {
					console.log(this.listdata.info,
						'this.listdata.infothis.listdata.infothis.listdata.infothis.listdata.info');
					if (this.listdata.info.sign_time_status == 1) {
						// 当前时间
						function timestampToTime(timestamp2) {
							var date = new Date(timestamp2); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
							var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
							var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
							var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
							return h + m + s;
						}
						var timestamp2 = Date.parse(new Date());
						let datatimeHMS = timestampToTime(timestamp2)
						// if (this.fromData.length != 0) {
						// 如果有数据就进行循环
						console.log('this.listdata.sign_time', this.listdata.sign_time);
						var _listdatamsg = this.listdata.sign_time
						var signtimeisyes = false
						for (let timeindex in _listdatamsg) {
							console.log(_listdatamsg[timeindex][0]);
							console.log(_listdatamsg[timeindex][1]);
							console.log(datatimeHMS, 'datatimeHMS');
							if (datatimeHMS > _listdatamsg[timeindex][0] && datatimeHMS < _listdatamsg[timeindex][1]) {
								console.log('签到时间正确！');
								_sendflag = true
								signtimeisyes = true
								break
							}
						}
						if (signtimeisyes == false) {
							uni.showToast({
								title: '签到时间错误！',
								duration: 2000,
								icon: "error"
							});
						}
					}

					for (var key in this.fromData) {
						// 手机号应该做一下判断
						console.log(this.fromData[key], 'this.fromData[key].from_data_type');

						// 如果有手机号并且手机号为必填的话
						// 如果手机号为选填，手机号要么不填，要么必须填对
						if (this.fromData[key].form_data_type == 10 && this.fromData[key].value != "") {
							let myreg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
							if (this.fromData[key].value && myreg.test(this.fromData[key].value)) {
								console.log("正确的电话号码")
							} else {
								uni.showToast({
									title: "请输入正确的号码",
									icon: "none"
								})
								return
							}
						}
						console.log(this.fromData[key].is_required, 'this.fromData[key].is_required');
						// 如果这个是个必填的选项，但是他没有进行 添值的话
						if (this.fromData[key].value == "" || this.fromData[key].value == [] || this.fromData[key]
							.value ==
							undefined) {
							if (this.fromData[key].is_required == 1) {
								uni.showToast({
									title: this.fromData[key].title + '是必填项',
									icon: "none",
									duration: 2000
								});
								_sendflag = false
								return
							}
						}
					}
					// 发送数据
					if (_sendflag) {
						let data = {};
						if (this.listdata.info.location_status == 1) {
							console.log('开启了位置信息');
							uni.getLocation({
								type: 'gcj02',
								success: (res) => {
									that.longitude = res.longitude;
									that.latitude = res.latitude;
									data = {
										code: that.code,
										from_data: JSON.stringify(that.fromData),
										lng: that.longitude,
										lat: that.latitude
									}
									signDo({
										data: data,
									}).then(res => {
										if (res.code == 1) {
											that.interstitialAd.show().catch((err) => {
												console.error(err)
											})

											uni.setStorage({
												key: 'dataArray',
												data: JSON.stringify(that.fromData),
												success: function() {
													console.log('success');
												}
											});

											const dataArray = uni.getStorageSync('dataArray');
											console.log(dataArray, 'dataArray');


											that.$refs.showMask.show();
										} else {
											this.showtoast = res.info
											console.log('signDo,res', res)
											that.$refs.showMaskerror.show();
										}

									})
									console.log('code:', that.code);
									console.log('code3:', that.longitude);
									console.log('code4:', that.latitude);
								},
								fail(res) {
									console.log(res)
									uni.getSetting({
										success: function(res) {
											var statu = res.authSetting
											if (!statu['scope.userLocation']) {
												uni.showModal({
													title: '是否授权当前位置',
													content: '需要获取您的地理位置，请确认授权，否则选择位置功能将无法使用',
													success: function(tip) {
														if (tip.confirm) {
															uni.openSetting({
																success: function(
																	data) {
																	if (data
																		.authSetting[
																			'scope.userLocation'
																		] ===
																		true) {
																		wx.showToast({
																			title: '授权成功',
																			icon: 'success',
																			duration: 1000
																		})
																		//授权成功之后，再调用chooseLocation选择地方
																		uni.getLocation({
																			type: 'gcj02',
																			success: (
																				res
																			) => {
																				that.longitude =
																					res
																					.longitude;
																				that.latitude =
																					res
																					.latitude;
																				data = {
																					code: that
																						.code,
																					from_data: JSON
																						.stringify(
																							that
																							.fromData
																						),
																					lng: that
																						.longitude,
																					lat: that
																						.latitude
																				}
																				signDo
																					({
																						data: data,
																					})
																					.then(
																						res => {
																							console
																								.log(
																									'signDo,res',
																									res
																								)
																							if (res
																								.code ==
																								1
																							) {
																								that.interstitialAd
																									.show()
																									.catch(
																										(
																											err
																										) => {
																											console
																												.error(
																													err
																												)
																										}
																									)
																								that.$refs
																									.showMask
																									.show();
																							} else {
																								this.showtoast =
																									res
																									.info
																								that.$refs
																									.showMaskerror
																									.show();
																							}
																						}
																					)
																				console
																					.log(
																						'code:',
																						that
																						.code
																					);
																				console
																					.log(
																						'code3:',
																						that
																						.longitude
																					);
																				console
																					.log(
																						'code4:',
																						that
																						.latitude
																					);
																			},
																		})


																	} else {
																		wx.showToast({
																			title: '授权失败',
																			icon: 'error',
																			duration: 1000
																		})
																	}
																}
															})
														}
													}
												})
											}
										},
										fail: function(res) {
											wx.showToast({
												title: '调用授权窗口失败',
												icon: 'error',
												duration: 1000
											})
										}
									})
								}

							});

						} else {
							data = {
								code: this.code,
								from_data: JSON.stringify(this.fromData),
							}
							signDo({
								data: data,
							}).then(res => {
								console.log('signDo,res', res)
								if (res.code == 1) {
									that.interstitialAd.show().catch((err) => {
										console.error(err)
									})

									that.saveDataArray(that.fromData)
									that.$refs.showMask.show();
								} else {
									this.showtoast = res.info
									that.$refs.showMaskerror.show();
									console.log(res.info);
								}
							})
						}
					}
				} else {
					uni.showToast({
						title: '当前签到已过期！',
						icon: "none",
						duration: 2000
					});
				}
			}
		}
	}
</script>
<style lang="scss" scoped>
	.container {
		background-color: #f6f6f6;
		padding: 0 20upx;
		min-height: 100vh;
		border: 1px solid rgba($color: #000000, $alpha: 0);

		.box {
			border-radius: 8upx;
			padding: 25upx;
			box-shadow: 0 0 6upx #cccccc;
			background-color: #fff;
			margin-top: 20upx;
		}

		.items {
			background-color: #fff;
			margin-top: 20upx;

			.heightmin {
				height: auto !important;
				min-height: 100upx !important;
			}

			.item {
				height: 100upx;
				border-bottom: 1px solid #EEEEEE;
				display: flex;
				align-items: center;
				line-height: 1;
				padding: 0 30upx;

				input {
					width: 70%;
					// margin-left: 60rpx;
				}
			}

			.moreoptionstyle {

				white-space: nowrap;
				width: 390rpx;
				overflow: hidden;
				/* scroll-x: inherit; */
				overflow-x: scroll;
			}

			.label {
				// display: inline-block;
				// width: 4em;
				// text-align: justify;  /*两端对齐*/
				// text-align-last: justify;

				text-align: center;
				width: 200rpx;
				font-size: 30upx;

			}

			.text {
				font-size: 28upx;
				width: 400upx;
			}
		}

		.fitst {
			.title {
				margin-bottom: 10upx;
			}

			.item {
				font-size: 26upx;
				color: #999;
				line-height: 45upx;
			}
		}

		.second {
			color: #8F939C;
			font-size: 26upx;
		}

		.button {
			color: #fff;
			font-size: 34upx;
			height: 85upx;
			display: flex;
			justify-content: center;
			align-items: center;
			background-color: #1e90ff;
			width: 700upx;
			margin: 0 auto;
			margin-top: 30upx;
			border-radius: 10upx;
		}

		.button1 {
			background-color: #c7c7c7;
		}

		.cover {
			width: 200upx;
			height: 200upx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.option {
			background-color: #fff;
			z-index: 666;
			width: 90vw;
			// margin-left: 10vw;
			// margin-top: 30vh;
			position: fixed;
			left: 5vw;
			top: 25vh;
			border-radius: 15upx;
			padding: 20upx;

			.title {
				width: 100%;
				height: 5vh;
				display: flex;
				line-height: 1;
				// align-items: center;
				justify-content: center;
				font-weight: 700;
			}

			.option-box {
				overflow: hidden;
				overflow-y: scroll;
				border: 1px solid #303133;
				width: 100%;
				max-height: 30vh;
				border-radius: 20upx;
				padding: 8upx;

				.height85 {
					height: 85upx !important;
					color: #FFFFFF;
					padding-left: 20upx;
					display: flex;
					align-items: center;
				}

				.item {
					margin-bottom: 8upx;
					background-color: #d3d3d3;
					border-radius: 20upx;
				}
			}

			.btns {
				display: flex;
				justify-content: space-between;

				.btn {
					margin-top: 22upx;
					height: 5vh;
					width: 40vw;
					background-color: #ff0000;
					height: 90upx;
					color: #fff;
					border-radius: 15upx;
					display: flex;
					align-items: center;
					justify-content: center;
				}


			}

			.bgblue {
				background-color: #1e90ff !important;
			}
		}

		.ad {
			margin-top: 20upx;
		}
	}
</style>
